<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta charset="utf-8">
            <title>淘天机站群系统管理后台</title>
            <!-- include header_meta -->
    </head>

    <body>
        <!-- include header -->
        <div class="cp-wrap {if $jnarrow}jnarrow{/if}">
            <div class="crumb"></div>
            <div class="cp-table-top cl">
                <div class="fl">
                    <input type="submit" class="btn" value="导入标题库" onclick="window.location.href = '?m=jsc&a=titleimport'"> 
                </div
            </div>
            <div class="cp-table">
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tbody>
                        <tr>
                            <th align="left">选择</th>
                            <th align="left">词库文件</th>
                            <th align="center">操作</th>
                        </tr>
                        <!-- foreach $lists $k $name-->
                        <tr>
                            <td align="left"><input type="checkbox" name="id" class="table-main" value="{$name}"></td>
                            <td align="left"><a href="/jscdata/keys/{$name}" target="_blank" class="unpjax">{$name}</a></td>
                            <td align="center">
                                <a href="javascript:void(0);" data-href="?m=jsc&a=del&id={$name}" class="deleteAction action_button fa fa-trash-o fa-fw" title="删除"></a>
                            </td>
                        </tr>
                        <!-- /foreach -->
                    </tbody>
                </table>
            </div>
            <div id="msg" style="padding-left:20px;color:red;"></div>
            <div class="cp-table-top">
                    <label>
                    <input type="checkbox" id="all" onclick="check_all()" />全选</label>&nbsp;
                    <a class="btn" id="del_all" href="javascript:void(0);">批量删除词库(谨慎操作)</a>
                    
            </div>
            <!-- if empty($list) -->
            <div class="noresult">暂时没有可显示数据</div>
            <!-- /if -->
            <div class="cp-pages">
                {$page}
            </div>
        </div>
        <!-- include footer -->
        <script type="text/javascript" src="__APPROOT__/js/layer/layer.js"></script>
        <script type="text/javascript">
            $(function(){
               $('.deleteAction').click(function(){
                  var i = $(this);
                  var tt = layer.confirm('确认要删除吗？', {
                    btn: ['是的','取消'] //按钮
                  }, function(){
                      layer.close(tt);
                      layer.prompt({title: '请输入管理员密码，并确认', formType: 1}, function(pass, index){
                        layer.close(index);
                        var href = i.attr('data-href');
                        $.post(href,{pass:pass},function(res){
                            if(res.suc==1) {
                                cpAlert('删除成功');
                                window.location.reload();
                            }else {
                                layer.msg(res.message);
                                return;
                            }
                         },'json');
                      });                  
                  }, function(){
                    layer.close(tt);
                  });
               });
               
               $('#del_all').click(function(){
                    var checkID = [];
                    $("input[name='id']:checked").each(function(i){
                        checkID[i] =$(this).val(); 
                    });
                    if(checkID.length==0) {
                        $("#msg").text("请最少选择一项！");
                        return false;
                    }else {
                        $("#msg").text("");
                    }
                    var tt = layer.confirm('确认要删除吗,这会导致已有的数据删除后不可找回？', {
                      btn: ['是的','取消'] //按钮
                    }, function(){
                        layer.close(tt);
                        layer.prompt({title: '请输入管理员密码，并确认', formType: 1}, function(pass, index){
                          layer.close(index);
                          $.post("?m=yuming&a=del",{pass:pass,id:checkID},function(res){
                              if(res.suc==1) {
                                  cpAlert('删除成功');
                                  window.location.reload();
                              }else {
                                  layer.msg(res.message);
                                  return;
                              }
                           },'json');
                        });                  
                    }, function(){
                      layer.close(tt);
                    });
               });
               
               
            });
            
            
            function check_all() {
                var ids = document.getElementById("all");
                if (ids.checked) {
                        $(".table-main").each(function() {
                                $(this).prop("checked", true);
                        })
                } else {
                        $(".table-main").each(function() {
                                $(this).prop("checked", false);
                        })
                }
            }
            
        </script>

        
    </body>

</html>